package com.lthlearn.service.impl;

import com.lthlearn.mapper.CollectMapper;
import com.lthlearn.mapper.TravelMapper;
import com.lthlearn.mapper.UserMapper;
import com.lthlearn.pojo.Result;
import com.lthlearn.pojo.Travel;
import com.lthlearn.pojo.User;
import com.lthlearn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author: 2942733239@qq.com
 * @date: 2024/11/4 11:10
 * @description: com.lthlearn.service.impl
 * @version: 1.0
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 根据邮箱查找用户
     *
     * @param email
     * @return
     */
    @Override
    public User getByEmail(String email) {
        return userMapper.findByEmail(email);
    }

    /**
     * 根据用户 id 查找当前用户收藏的所有景点 id 集合，
     * 再去景点表中查找所有景点信息
     *
     * @param userId
     * @return
     */
    @Override
    public Result getCollectByUserIdAndPlaceIds(Integer userId) {
        User user = userMapper.findCollectByUserIdAndPlaceIds(userId);
        if (user == null) {
            return new Result("500","查询失败");
        }
        return new Result("200","查询成功",user);
    }
}
